#include "pch.h"
#include "DimensionCamera.h"
#include <unordered_map>

#define USE_DAHENG
#define USE_HIK

#ifdef USE_DAHENG
#include "CamDaheng.h"
#endif

#ifdef USE_HIK
#include "CamHikVision.h"
#endif

DimensionCamera::~DimensionCamera() {
	for (auto& cm : CameraMap) {
		delete cm.second;
	}
	CameraMap.clear();
}

const char* DimensionCamera::type() {
	return typeid(DimensionCamera).name();
}

void DimensionCamera::InfoFramegrabber(std::string type, std::string info, DStringList* Info, DStringList* ValueList)
{
	HandleList.clear();
	CameraMap.clear();

	{
		DStringList _Info, _ValueList;
		CamDaheng* cam = new CamDaheng();
		cam->InfoFramegrabber("SDK", "info_boards", &_Info, &_ValueList);
		if (cam->HandleList.size() > 0) {
			CameraMap[cam->type()] = cam;
		}
	}

	{
		DStringList _Info, _ValueList;
		CamHikVision* cam = new CamHikVision();
		cam->InfoFramegrabber("SDK", "info_boards", &_Info, &_ValueList);
		if (cam->HandleList.size() > 0) {
			CameraMap[cam->type()] = cam;
		}
	}
}

int DimensionCamera::OpenFramegrabberSimgple(DimInfo * dimInfo, std::string SnapMethod)
{
	std::cout << "Error Virtual funciton should not be called\n";
	return DIM_ERROR_VIRTUAL_FUNCTION;
}

bool DimensionCamera::GrabImage(AcqHandle, DimInfo * ImageData)
{
	return false;
}

std::unordered_map<std::string, DimensionCamera*>& DimensionCamera::getCameraInfoByVendorNameCameraMap()
{
	return CameraMap;
}
